<?php
session_start();//启用回话窗
// 存储 session 数据
$_SESSION['note']=$_POST['userName'];

// 创建连接
$conn = new mysqli("localhost", "root","wei1995629", "information");

// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}

$sql = "SELECT * FROM userInformation WHERE userName='{$_POST['userName']}' and password='{$_POST['password']}'";

if(!mysqli_query($conn, $sql))
    {echo "error";
    }
else 
    {   
        $row =mysqli_query($conn, $sql)->fetch_assoc();
        $time = TIMESTAMP;//获取登陆时间
        $sqltime = "UPDATE userInformation SET reg_date =$time WHERE userName='{$_POST['userName']}' and password='{$_POST['password']}' ";
        mysqli_query($conn,$sqltime);//更新登陆时间
        if("ADMIN" == $row["admin"]){//判断是否拥有管理员权限
            header("Location:adminInterface.php"); //跳转管理员界面
        }
        else{
            header("Location:userInterface.php"); //跳转用户界面
        } 
    }

$conn->close();
?>